<template>
    <div>
        <el-breadcrumb separator-class="el-icon-arrow-right">
            <el-breadcrumb-item :to="{ path: '/home' }">首页</el-breadcrumb-item>
            <el-breadcrumb-item>订单管理</el-breadcrumb-item>
            <el-breadcrumb-item>订单列表</el-breadcrumb-item>
        </el-breadcrumb>
        <el-card>
            <el-row>
                <el-col :span="8">
                    <el-input>
                        <el-button slot="append" icon="el-icon-search"></el-button>
                    </el-input>
                </el-col>
            </el-row>
            <el-table :data="orderList" border stripe>
                <el-table-column type="index"></el-table-column>
                <el-table-column label="编号" prop="order_number"></el-table-column>
                <el-table-column label="订单价格" prop="order_price"></el-table-column>
                <el-table-column label="是否付款" prop="pay_status">
                    <template slot-scope="scope">
                       <el-tag type="success" v-if="scope.row.pay_status === '1'">已付款</el-tag>
                       <el-tag type="danger" v-else>未付款</el-tag>
                    </template>
                </el-table-column>
                <el-table-column label="是否发货" prop="is_send"></el-table-column>
                <el-table-column label="下单时间">
                    <template slot-scope="scope">
                        {{scope.row.create_time|dataFormat}}
                    </template>
                </el-table-column>
                <el-table-column label="操作" >
                    <template slot-scope="">
                        <el-button type="primary" size="mini" icon="el-icon-edit"></el-button>
                        <el-button type="success" size="mini" @click="showProgress" icon="el-icon-location"></el-button>
                    </template>
                </el-table-column>
            </el-table>
            <el-pagination
                @size-change="handleSizeChange"
                @current-change="handleCurrentChange"
                :current-page="queryInfo.pagenum"
                :page-sizes="[6, 10]"
                :page-size="total"
                layout="total, sizes, prev, pager, next, jumper"
                :total="400">
            </el-pagination>
        </el-card>
        <el-dialog
            title="提示"
            :visible.sync="expressDialogVisible"
            width="50%"
           >
            <el-timeline>
                <el-timeline-item
                v-for="(activity, index) in progressInfo"
                :key="index"
                :timestamp="activity.time">
                {{activity.context}}
                </el-timeline-item>
            </el-timeline>
            <span slot="footer">
                <el-button @click="expressDialogVisible = false">取 消</el-button>
                <el-button type="primary" @click="clickExpress">确 定</el-button>
            </span>
        </el-dialog>
    </div>
</template>

<script>
export default {
    data() {
        return {
            queryInfo: {
                query: '',
                pagesize: 10,
                pagenum: 1
            },
            orderList: [],
            total: 0,
            expressDialogVisible: false,
            progressInfo: []
        }
    },
    created() {
        this.getOrderList()
    },
    methods: {
        async getOrderList() {
            const {data: res} = await this.$http.get('orders', {params: this.queryInfo})
            if (res.meta.status !== 200) return this.$message.error('获取失败')
            this.orderList = res.data.goods
            this.total = res.data.total
        },
        handleSizeChange(val){
            this.queryInfo.pagesize = val
            this.getOrderList()
        },
        handleCurrentChange(val){
            this.queryInfo.pagenum = val
            this.getOrderList()
        },
        clickExpress() {
            this.expressDialogVisible = false
        },
        async showProgress() {
            const {data: res} = await this.$http.get('kuaidi/804909574412544580')
            if(res.meta.status !== 200) return this.$message.error('获取快递信息失败')
            this.progressInfo = res.data
            console.log(this.progressInfo)
            this.expressDialogVisible = true
        },
        handleClose() {

        }
        
    }
}
</script>
<style  scoped>
    
</style>